﻿using System;
using System.Text;
using System.Collections;
using System.Xml;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Resources;
using System.Reflection;
using System.Globalization;
using System.Threading;

using Telerik.WebControls;
using UFSoft.UBF.UI.WebControls;
using UFSoft.UBF.UI.Controls;
using UFSoft.UBF.Util.Log;
using UFSoft.UBF.Util.Globalization;

using UFSoft.UBF.UI.IView;
using UFSoft.UBF.UI.Engine;
using UFSoft.UBF.UI.MD.Runtime;
using UFSoft.UBF.UI.ActionProcess;
using UFSoft.UBF.UI.WebControls.ClientCallBack;
using System.Collections.Generic;
using UFIDA.U9.Cust.SH.SHFastShipUI.Pub;
using UFIDA.U9.Cust.SH.SHFastShipBP;
using UFIDA.U9.Cust.SH.SHFastShipBP.Proxy;



/***********************************************************************************************
 * Form ID: 
 * UIFactory Auto Generator 
 ***********************************************************************************************/
namespace UFIDA.U9.Cust.SH.SHSOListBListUIModel
{
    public partial class SHSOListBListUIFormWebPart
    {
        #region Custome eventBind


        private void OnCreateDoc_Click_Extend(object sender, EventArgs e)
        {
            //调用模版提供的默认实现.--默认实现可能会调用相应的Action.
            this.Model.ClearErrorMessage();

            List<long> ids=new List<long>();
            //List<IUIRecord> list=GetSelectedRecord();
            IList<IUIRecord> list = this.Model.SOShipline.Cache.GetSelectRecord();
            foreach (IUIRecord record in list)
            {
                long solineid = PubTool.ToLong(record["SOLine"].ToString());
                if (!ids.Contains(solineid) && solineid > 0)
                {
                    ids.Add(solineid);
                }
            }
            if (ids.Count > 0)
            {
                long custid = PubTool.ToLong( this.ParameterValues["CustID"].ToString());
                long whid = PubTool.ToLong(this.ParameterValues["WHID"].ToString());
                if (custid <= 0) throw new Exception("请先录入客户！");

                GetSOLineInfoProxy proxy = new GetSOLineInfoProxy();
                proxy.SOLineIDs = ids;
                proxy.CustID = custid;
                proxy.WH = whid;
                List<ItemInfoDTOData> dtos = proxy.Do();
                if (dtos.Count <= 0) throw new Exception("没有生单记录，不能生成快速出货单！");

                this.CurrentState["SHSOLineInfos"] = dtos;
                this.CloseDialog(true);
            }
            else
                throw new Exception("请选择记录!");

            OnCreateDoc_Click_DefaultImpl(sender, e);
        }

        private List<IUIRecord> GetSelectedRecord()
        {
            List<IUIRecord> recs = new List<IUIRecord>();
            long[] ids = this.Model.SOShipline.GetSelectedRecordIDs();
            foreach (long id in ids)
            {
                IUIRecord rec = this.Model.SOShipline.Records.FindByKey(id);
                if (rec == null) continue;
                recs.Add(rec);
            }
            return recs;


        }


        private void FastQuery_Click_Extend(object sender, EventArgs e)
        {
            //调用模版提供的默认实现.--默认实现可能会调用相应的Action.

            this.CurrentState["SODocNo"] = this.tbSODocNo.Text;
            this.CurrentState["LotCode"] = this.tbLotCode.Text;

            FastQuery_Click_DefaultImpl(sender, e);
        }	

				//BtnNew_Click...
		private void BtnNew_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			BtnNew_Click_DefaultImpl(sender,e);
		}	
		 
				//BtnDelete_Click...
		private void BtnDelete_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			BtnDelete_Click_DefaultImpl(sender,e);
		}	
		 
				//BtnOutPut_Click...
		private void BtnOutPut_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			BtnOutPut_Click_DefaultImpl(sender,e);
		}	
		 
				//BtnPrint_Click...
		private void BtnPrint_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			BtnPrint_Click_DefaultImpl(sender,e);
		}	
		 

			

		//DDLCase_TextChanged...
		private void DDLCase_TextChanged_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			DDLCase_TextChanged_DefaultImpl(sender,e);
		}	
		 
				//OnLookCase_Click...
		private void OnLookCase_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			OnLookCase_Click_DefaultImpl(sender,e);
		}	
		 
			
				

		//DataGrid1_GridRowDbClicked...
		private void DataGrid1_GridRowDbClicked_Extend(object sender, GridDBClickEventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			DataGrid1_GridRowDbClicked_DefaultImpl(sender,e);
		}

		
            
            
            

		#region 自定义数据初始化加载和数据收集
		private void OnLoadData_Extend(object sender)
		{	
			OnLoadData_DefaultImpl(sender);
		}
		private void OnDataCollect_Extend(object sender)
		{	
			OnDataCollect_DefaultImpl(sender);
		}
		#endregion  

        #region 自己扩展 Extended Event handler 
		public void AfterOnLoad()
		{
			
			AfterOnLoad_Qry_DefaultImpl();//BE列表自动产生的代码
	    
		}

        public void AfterCreateChildControls()
        {
									
			AfterCreateChildControls_Qry_DefaultImpl();//BE列表自动产生的代码
		

		
        }
        
        public void AfterEventBind()
        {
        }
        
		public void BeforeUIModelBinding()
		{
								
		}

		public void AfterUIModelBinding()
		{
									
			AfterUIModelBinding_Qry_DefaultImpl();//BE列表自动产生的代码
            SetControlState();

		}

        private void SetControlState()
        {
            BtnNew.Visible = false;
            BtnDelete.Visible = false;
            BtnPrint.Visible = false;
            BtnOutPut.Visible = false;
        }


        #endregion
		
        #endregion
		
    }
}